const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    loading: true,
    card_num:0,
    card: [],
    page: 0,
  },
  //监听页面加载
  onShow: function () {
    this.getApi();
  },
  //底部加载更多
  onReachBottom: function () {
    this.setData({
      loading: true,
    });
    this.getCoupon();
  },
  //读取我的订单
  getApi: function () {
    if (this.data.loading) {
      var param = {
        signkey: app.util().getRandom(12),
        page: this.data.page+1,
      }
      app.api().Get("api/v4/allwin/card/userCard",param,(result)=>{
        if (result.code == 200) {
          var card = this.data.card;
          for (let i in result.data) {
            card.push(result.data[i]);
          }
          this.setData({
            card: card,
            page: param.page,
          });
        }
        this.setData({
          loading: false
        })
      })
      this.setData({
        loading: false
      })
    }
  }
})